﻿<%@ Page Title="" Language="C#" MasterPageFile="~/ZFMaster.Master" AutoEventWireup="true"
    CodeBehind="life.aspx.cs" Inherits="ZF.WS.fz.life" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script src="../js/jqPlugins/jquery.json-2.2.min.js" type="text/javascript"></script>

    <style>
        .gptype { text-align: center; padding-left: 00px; width: 780px; float: left; }
         
        .gptype li { cursor: pointer; float: left;width: 90px; *width: 50px; margin-right: 5px; margin-top: 10px; }
        .gptype li a, a.xy { text-align: center; padding: 0px 2px; display: block; width: 86px; height: 30px; border: 1px solid #BCDDF4; background: #fdfdfd; line-height: 30px; color: #1D73B0; font-size: 14px; font-weight: bold; }
        .gptype li a:hover, a:hover.xy { border: 1px solid #eee; background: #1D73B0; color: #fff; }
        .gptype .drag { width: 580px; height: 500px; overflow: scroll; display: none; filter: alpha(opacity=95); -moz-opacity: 0.9; opacity: 0.9; position: absolute; background: #fff; }
        .gptype .drag .close { cursor: pointer; }
        .gptype .drag dd { height: 300px; }
        .gptype .drag dd li { float: left; width: 100px; height: 100px; text-align: center; margin: 5px; border-bottom: 1px solid #ddd; }
        .gptype .drag dd li img { width: 100px; height: 100px; }
        .gptype .drag dd li p { margin-bottom: 2px; }
    </style>
    <div class="location mb10_">
        您现在的位置：<a href="/"><%=SiteInfo.Instance.SystemConfig.SiteName %></a>>> <a href="list.aspx">
            佛祖列表</a> >> <a href="<%=this.Request.Url %>">在线礼佛</a>
    </div>
    <table>
        <tr>
            <td style="width: 200px" valign="top" style="">
                <div style="border: 1px solid #bbb; padding: 5px;">
                    <p>
                        <img src="/photo/game/<%=this.Buddha.Photo %>" style="border: 1px solid #bbb;" />
                    </p>
                    <p style="margin-top: 10px; color: #f00; font-weight: bold; font-size: 14px; text-align: center;">
                        <span>
                            <%=this.Buddha.Name %></span></p>
                </div>
                <div style="margin-top: 05px">
                    <dl>
                        <dt style="font-weight: bold; line-height: 30px; height: 30px; border-bottom: 1px solid #f00;
                            text-align: center;">
                            <%=this.Buddha.Name %>简介</dt>
                        <dd style="text-align: left; padding-top: 5px;">
                            .
                            <textarea style="text-indent: 2em; height: 360px; width: 100%; border: 0px; line-height: 20px;"><%=this.Buddha.Remark %></textarea>
                        </dd>
                        <dd style="text-align: left; margin-top: 10px;">
                            <p style="border-bottom: 1px solid #eee; color: #fff; height: 24px; line-height: 24px;
                                color: #f00">
                                切换到其他佛祖:
                            </p>
                            <p style="margin-top: 5px;">
                                <zf:DropDownList runat="server" ID="ddlFZ" class="ddl ddlfz">
                                </zf:DropDownList>
                            </p>

                            <script>
                                $(".ddlfz").change(function() {
                                    window.location = "life.aspx?id=" + this.value;
                                });
                            </script>

                        </dd>
                    </dl>
                </div>
            </td>
            <td style="width: 10px" valign="top">
            </td>
            <td style="width: 780px" valign="top">
                <div class="1dn_">
                    <div class="board">
                        <dl>
                            <dt><a href="javascript:" class="active slide" bind="s1">在线礼佛</a> <a href="javascript:"
                                class=" slide" bind="s2">最新许愿字句</a> </dt>
                            <dd class="slide s1 ">
                                <iframe src="fx.aspx?id=<%=this.Buddha.BuddhaId %>" id="fx" style="width: 780px;
                                    height: 490px" frameborder="no" border="0" marginwidth="0" scrolling="no" marginheight="0"
                                    allowtransparency="yes"></iframe>
                            </dd>
                            <dd class="slide s2 dn_">
                                <div style="width: 780px; height: 490px">
                                    <div>
                                        <style>
                                            .comment { }
                                            .comment dl { border: 1px solid #eee; line-height: 20px; color: #666; text-align: left; }
                                            .comment dt { height: 30px; line-height: 30px; border-bottom: 1px dashed #eee; }
                                            .comment dd { padding: 10px 00px; }
                                            .comment dd { line-height: 20px; width: 110px; color: #666; }
                                            .comment span { color: #0099FF; font-weight: bold; }
                                        </style>
                                        <div class="commentc" style="height: 490px; overflow: scroll;">
                                            <div class="comment">
                                                <zf:ListView runat="server" ID="lvXY">
                                                    <LayoutTemplate>
                                                        <div style="">
                                                            <zf:PlaceHolder ID="itemPlaceHolder" runat="server">
                                                            </zf:PlaceHolder>
                                                        </div>
                                                    </LayoutTemplate>
                                                    <ItemTemplate>
                                                        <dl>
                                                            <span>[<%#Eval("Name") %>]</span>
                                                            <%#((string)Eval("Msg")).EmptyString("").Replace("\r\n","</br>") %>
                                                            <%# ((DateTime)Eval("Wishing.AddTime")).ToShortDateString()%>
                                                        </dl>
                                                    </ItemTemplate>
                                                </zf:ListView>
                                            </div>
                                        </div>

                                        <script>
                                            if ($(".comment").height() < $(".commentc").height()) {
                                                if ($(".comment").height() > 0) {
                                                    $(".commentc").height($(".comment").height() + 20)
                                                } else {
                                                    $(".commentc").height(0);
                                                }
                                            }
                                        </script>

                                    </div>
                                </div>
                            </dd>
                        </dl>
                    </div>
                    <div class="gptype">
                        <ul>
                            <zf:ListView runat="server" ID="lvGPTitle">
                                <LayoutTemplate>
                                    <zf:PlaceHolder ID="itemPlaceHolder" runat="server">
                                    </zf:PlaceHolder>
                                </LayoutTemplate>
                                <ItemTemplate>
                                    <li><a bind="<%#Container.DataItemIndex %>" href="javascript:">
                                        <%#Eval("Key") %></a></li>
                                    <div class="board drag gpc" t="<%#Container.DataItemIndex %>">
                                        <dl>
                                            <dt><span>
                                                <%#Eval("Key") %></span> <a class="more close" style="width: 50px; *padding-top: 5px;">
                                                    关闭<img src="/images/tab-close.gif" /></a> </dt>
                                            <zf:ListView ID="ListView1" runat="server" DataSource='<%#Eval("Value") %>'>
                                                <LayoutTemplate>
                                                    <dd>
                                                        <ul>
                                                        </ul>
                                                    </dd>
                                                    <zf:PlaceHolder ID="itemPlaceHolder" runat="server">
                                                    </zf:PlaceHolder>
                                                </LayoutTemplate>
                                                <ItemTemplate>
                                                    <li>
                                                        <p class="gpp">
                                                            <img src="/photo/game/<%#Eval("Path")  %>" class="buy" bind="<%#Eval("OfferingId")%>"
                                                                inte="<%#Eval("Memoy")%>" />
                                                        </p>
                                                        <p>
                                                            <span>
                                                                <%#Eval("Name") %></span></p>
                                                        <p>
                                                            <span>积分:<%#Eval("Memoy")%></span>
                                                            <input type="button" class="buy" bind="<%#Eval("OfferingId")%>" inte="<%#Eval("Memoy")%>"
                                                                value="使用" /></p>
                                                    </li>
                                                </ItemTemplate>
                                            </zf:ListView>
                                        </dl>
                                    </div>
                                </ItemTemplate>
                            </zf:ListView>
                        </ul>
                    </div>
                    <div class="fc_">
                    </div>
                    <div class="mt10_ tal_   " style="height: 50px; width: 780px;">
                        <textarea id="msg" style="width: 672px; height: 100px; float: left; font-size: 16px;"></textarea>
                        <a class="xy" href="javascript:" inte="0" bind="19" style="height: 100px; line-height;
                            100px; vertical-align: middle;">
                            <br />
                            许愿</a>
                    </div>
                </div>
            </td>
        </tr>
    </table>

    <script>
              var integral=<%=CMember == null ? 0 : CMember.Integral %>
            var ismember=<%=CMember == null ? "false" : "true" %>
            var bid=<%=Buddha.BuddhaId %>;
            var memberAccount="<%=CMember!=null?CMember.Account:"" %>";
            var JFBFJF=$.evalJSON('<%=Newtonsoft.Json.JsonConvert.SerializeObject(SiteInfo.SystemConfig.JFBFJF) %>');
    </script>

    <script>

        $(function() {
            var isxy = false;
            var fx = window.frames["fx"];
            $(".drag .buy").click(function() {
                var x = 380;
                var y = 330;


                var money = parseInt($(this).attr("inte"));
                if (!ismember) {
                    alert("请登录后操作");
                    window.location = "/login.aspx?from=" + window.location;
                    return;
                } else {
                    if (integral < money && money != 0) {
                        alert("您当前的积分不足以购买该供品，请充值");
                        return;
                    }
                }
                var result = buy($(this).attr("bind"), x, y, "", 0);

                if (result.result) {
                    var html = $(this.parentNode.parentNode).find(".gpp").html();
                    fx.add(html, result.data, x, y);
                } else {
                    alert(result.data);
                }
                $(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode).find(".close")[0].click();

            });


            $(".xy").click(function() {
                var msglen = $("#msg").val().length;
                if (msglen == 0) {
                    alert("请输入许愿内容");
                    return false;
                }
                var money = 0;
                if (JFBFJF.BaseZC < msglen) {
                    var cl = msglen - JFBFJF.BaseZC;
                    var dz = parseInt(cl / JFBFJF.BFDZZC) * JFBFJF.BFDZJF;

                    if (cl % JFBFJF.BFDZZC > 0) {
                        dz += JFBFJF.BFDZJF;
                    }
                    money = JFBFJF.BaseJF + dz;

                } else {
                    money = JFBFJF.BaseJF;
                }

                if (!ismember) {
                    alert("请登录后操作");
                  
                    window.location = "/login.aspx?from=" + window.location;
                    return;
                } else {
                    if (integral < money && money != 0) {
                        alert("您当前的积分不足，请充值");
                        return;
                    }
                }

                confirm(String.format("当前许愿操作将扣除你{0}个积分，是否继续", money));
                var result = buy(0, 0, 0, $("#msg").val(), 1);

                if (result.result) {
                    $("#msg").val("");
                    addXY(memberAccount, result.data);
                } else {
                    alert(result.data);
                }
            });
        });
        function addXY(name, content) {
            var template = "<dl class='new'><span>[{0}]</span> {1} </dl>";
            $(".comment").append(String.format(template, name, content));
            $(".commentc")[0].scrollTop = $(".commentc")[0].scrollHeight;
        }
        function buy(oid, x, y, msg, type) {
            var params = { oid: oid, bid: bid, x: x, y: y, msg: msg, type: type };
            var result = null;
            $.ajax({
                url: "lfHandler.ashx",
                cache: false,
                async: false,
                type: "POST",
                data: String.format("params={0}", $.toJSON(params)),
                success: function(html) {

                    var json = $.evalJSON(html);
                    result = json;
                }
            });
            return result;
        }
             
    </script>

    <script>
        $(function() {
            var fxl = $("#fx").position().left;
            var fxt = $("#fx").position().top;
            var fxw = $("#fx").width();
            var fxh = $("#fx").height();
            $(".drag").each(function() {
                var dw = $(this).width();
                var dh = $(this).height();

                $(this).css({ left: fxl + ((fxw - dw) / 2), top: fxt + (fxh - dh) / 2 });

                var drag = this;
                $(this).find(".close").click(function() {

                    $(drag).hide();
                });
            });
            $(".gptype li a").click(function() {
                var id = $(this).attr("bind");
                $(".drag").hide();
                $(String.format(".drag[@t='{0}']", id)).show();
            });


        });
    </script>

</asp:Content>
